All Questions
33 questions
1vote
0answers
99views
Why is dividing a uint8 numpy array by a float32 faster than explicit type conversion?
I am working with some image data so the images are represented as numpy arrays with shape (1404, 1404, 3). The image is of type np.uint8 (it has RGB values from 0 to 255) I am wondering about the ...
0votes
1answer
401views
How to convert from cv2 findContours to np array when there are multiple arrays in the contours?
I have a picture of a simple black and white mandala. I'm using Python and cv2 and numpy. My goal is to get the contour as X, Y coordinates and save them in a gcode file. The problem is that I get as ...
-1votes
1answer
55views
Sum of postive intergers in a list is negative
I am trying to calculate intensities in different regions in a image(taken in 16-bit). I have created binary masks first of the different regions, then using the masking I calculate the intensities. ...
1vote
0answers
39views
I can't use coordinate values in list for hough line function
I want to use the Hough line function. When I look at my list, yes, I found the coordinate values of the edges, but when I want to plot it in a for loop, I get an error. Here is the error message: ...
0votes
0answers
60views
Import an image as a 2D array of RGB tuples rather than a 3D array of values [duplicate]
Is there a NumPy function or "way" to directly import an image as a 2D array of RGB 3-tuples instead of the usual 3D array of values? So far, I've arrived at this solution: from PIL import ...
0votes
1answer
186views
Image Convolution with callback function in python
I want to loop over the pixels of a binary image in python and set the value of a pixel depending on a surrounding neighborhood of pixels. Similar to convolution but I want create a method that sets ...
0votes
0answers
444views
Error using OpenCV for Connected Components on numpy arrays
I'm trying to do a connected component analysis on an image using OpenCV in python. The images are in a '.czi' format so I am using aicsimageio to import the file into numpy array. However, I keep ...
0votes
1answer
364views
Why doesn't my blur matrix filter blur the photo, and why does it make it darker?
I am at a loss here, sorry if this question seems stupid. I have the following code that should return a blurred image of a cat: def convolve(image, kernel): #IMPLEMENT HERE image_copy=image.copy()...
1vote
2answers
486views
Show a 2d numpy array where contents are tuples as an image
I have a 2d (M * N) numpy array, where each cell contains a tuple of length 3. The tuple contains R, G, and B values for each pixel, e.g. A[0,0] = (0, 255, 0) Is there a way to show this array as an ...
0votes
1answer
302views
Get a portion of the original image and put it onto another image using numpy array
I have two pictures, 1 of a minion with green background and one of a cat. I want to get the minion from the first and image and put it in front of the cat in the 2nd page. I have written the code for ...
-2votes
1answer
69views
Can not rashape a numpy array
I have the following code, which should decrease the width of an image passed as a numpy array by one. Array seam has the column-indices of the pixels to be deleted from corresponding row. To do the ...
0votes
0answers
407views
Change resolution of a image in ndarray format without changing dimensions in pixel
In my specific case I have volumes in nifti format (CT images), which I convert to ndarray format in order to do a series of preprocessing operations. Among these I should decrease the resolution of ...
2votes
1answer
92views
How can I simplify the following code so it runs faster?
I have a three-dimensional array containing many 2D images (frames). I want to remove the background by considering a threshold for each pixel value and copy new elements in a new 3D array. I wrote ...
0votes
1answer
62views
Finding a multi-value submatrix with wildcards
I have a matrix with these values (if it helps, this an rgb image): mat = np.array([ [[0, 0, 0], [123, 0, 255], [0, 0, 0]], [[0, 0, 0], [123, 0, 255], [45, 0, 54]], [[0, 0, 0], [100, 0, ...
2votes
2answers
153views
Filter a numpy ndarray using another numpy ndarray
I have two numpy ndarrays of the same shape (15081, 56724, 3, 3). What I want to do is as follows: Say we have a cross section of the first array, array1[1, 1, :, :], looks like this: [[120, 110, 220],...